package com.tinshow.config.configuration;

import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.session.Session;
import org.springframework.session.SessionRepository;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.*;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.Properties;

/**
 * Created by libo4 on 2017/6/28.
 */
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds= 3600 *24 * 7)
public class RedisSessionConfig {

    @Bean
    public HttpSessionStrategy httpSessionStrategy() {
        return new HeaderHttpSessionStrategy();
    }

//    @Bean
//    public SessionRepositoryFilter sessionRepositoryFilter(SessionRepository<? extends Session> sessionRepository){
//        Properties properties = new Properties();
//        properties.setProperty("",cookieHttpSessionStrategy);
//        return new SessionRepositoryFilter(sessionRepository);
//    }
//
//    @Bean
//    public CookieHttpSessionStrategy cookieHttpSessionStrategy(){
//        CookieHttpSessionStrategy cookieHttpSessionStrategy = new CookieHttpSessionStrategy();
//        cookieHttpSessionStrategy.setCookieName("SessionId");
//        return cookieHttpSessionStrategy;
//    }

//    @Bean
//    public CookieSerializer cookieSerializer() {
//        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
//        serializer.setCookieName("SessionId");
//        serializer.setCookiePath("/");
//        serializer.setDomainNamePattern("^.+?\\.(\\w+\\.[a-z]+)$");
//        return serializer;
//    }
}
